home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  52.1 KB  |  1,462 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT OSA;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __OSA__}
  27. {$SETC __OSA__ := 1}
  28.  
  29. {$I+}
  30. {$SETC OSAIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __APPLEEVENTS__}
  40. {$I AppleEvents.p}
  41. {$ENDC}
  42. {    Types.p                                                        }
  43. {    Memory.p                                                    }
  44. {        MixedMode.p                                                }
  45. {    OSUtils.p                                                    }
  46. {    Events.p                                                    }
  47. {        Quickdraw.p                                                }
  48. {            QuickdrawText.p                                        }
  49. {    EPPC.p                                                        }
  50. {        PPCToolbox.p                                            }
  51. {            AppleTalk.p                                            }
  52. {        Processes.p                                                }
  53. {            Files.p                                                }
  54. {    Notification.p                                                }
  55.  
  56. {$IFC UNDEFINED __AEOBJECTS__}
  57. {$I AEObjects.p}
  58. {$ENDC}
  59.  
  60. {$IFC UNDEFINED __COMPONENTS__}
  61. {$I Components.p}
  62. {$ENDC}
  63.  
  64. {$PUSH}
  65. {$ALIGN MAC68K}
  66. {$LibExport+}
  67.  
  68. CONST
  69.     kOSAComponentType            = 'osa ';
  70.  
  71. { 0x73637074 }
  72.     kOSAGenericScriptingComponentSubtype = 'scpt';
  73.  
  74. {    Type of script document files.    }
  75. { 0x6f736173 }
  76.     kOSAFileType                = 'osas';
  77.  
  78. {
  79.         Suite and event code of the RecordedText event. 
  80.         (See OSAStartRecording, below.)
  81.     }
  82. { 0x61736372 }
  83.     kOSASuite                    = 'ascr';
  84.  
  85. { 0x72656364 }
  86.     kOSARecordedText            = 'recd';
  87.  
  88. { Selector returns boolean }
  89. { 0x6d6f6469 }
  90.     kOSAScriptIsModified        = 'modi';
  91.  
  92. { Selector returns boolean }
  93. { 0x63736372 }
  94.     kOSAScriptIsTypeCompiledScript = 'cscr';
  95.  
  96. { Selector returns boolean }
  97. { 0x76616c75 }
  98.     kOSAScriptIsTypeScriptValue    = 'valu';
  99.  
  100. { Selector returns boolean }
  101. { 0x636e7478 }
  102.     kOSAScriptIsTypeScriptContext = 'cntx';
  103.  
  104. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  105. { 0x62657374 }
  106.     kOSAScriptBestType            = 'best';
  107.  
  108. {
  109.         This selector is used to determine whether a script has source 
  110.         associated with it that when given to OSAGetSource, the call will not
  111.         fail.  The selector returns a boolean.
  112.     }
  113. { 0x67737263 }
  114.     kOSACanGetSource            = 'gsrc';
  115.  
  116.     typeOSADialectInfo            = 'difo';                        {  0x6469666f   }
  117.     keyOSADialectName            = 'dnam';                        {  0x646e616d   }
  118.     keyOSADialectCode            = 'dcod';                        {  0x64636f64   }
  119.     keyOSADialectLangCode        = 'dlcd';                        {  0x646c6364   }
  120.     keyOSADialectScriptCode        = 'dscd';
  121.  
  122.     
  123. TYPE
  124.     OSAError = ComponentResult;
  125.  
  126. { Under the Open Scripting Architecture all error results are longs }
  127.     OSAID = LONGINT;
  128.  
  129. {
  130.         OSAIDs allow transparent manipulation of scripts associated with
  131.          various scripting systems.
  132.     }
  133.  
  134. CONST
  135.     kOSANullScript                = 0;
  136.  
  137. { No -script constant. }
  138.     kOSANullMode                = 0;                            { sounds better }
  139.     kOSAModeNull                = 0;                            { tastes consistent }
  140.  
  141. {
  142.         Some routines take flags that control their execution.  This constant
  143.         declares default mode settings are used.
  144.     }
  145. TYPE
  146.     OSACreateAppleEventProcPtr = ProcPtr;  { FUNCTION OSACreateAppleEvent(theAEEventClass: AEEventClass; theAEEventID: AEEventID; (CONST)VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr; }
  147.     OSACreateAppleEventUPP = UniversalProcPtr;
  148.  
  149. CONST
  150.     uppOSACreateAppleEventProcInfo = $000FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  151.  
  152. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  153.     {$IFC NOT GENERATINGCFM }
  154.     INLINE $2E9F;
  155.     {$ENDC}
  156.  
  157. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  158.     {$IFC NOT GENERATINGCFM}
  159.     INLINE $205F, $4E90;
  160.     {$ENDC}
  161. TYPE
  162.     OSASendProcPtr = ProcPtr;  { FUNCTION OSASend((CONST)VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr; }
  163.     OSASendUPP = UniversalProcPtr;
  164.  
  165. CONST
  166.     uppOSASendProcInfo = $003FEFE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  167.  
  168. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  169.     {$IFC NOT GENERATINGCFM }
  170.     INLINE $2E9F;
  171.     {$ENDC}
  172.  
  173. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  174.     {$IFC NOT GENERATINGCFM}
  175.     INLINE $205F, $4E90;
  176.     {$ENDC}
  177. {*************************************************************************
  178.     Standard Script Errors
  179. **************************************************************************
  180.     It is recommended that scripting components use the following set of error
  181.     codes to signal failure when applicable.  This enables applications that
  182.     use the OSA API to deal with some class of script errors in a less than 
  183.     ad hoc manner.  Scripting components are of course encouraged to return
  184.     component-specific errors when these don't apply.
  185. *************************************************************************}
  186. {        Dynamic errors:
  187.  
  188.     These errors result from data-dependent conditions and are typically
  189.     signaled at runtime.
  190. }
  191. {
  192.         Signaled when a value can't be coerced to the desired type. Similar
  193.           to errOSATypeError except results from coercion.
  194.     }
  195.  
  196. CONST
  197.     errOSACantCoerce            = errAECoercionFail;
  198.  
  199. { Signaled when an object is not found in a container }
  200.     errOSACantAccess            = errAENoSuchObject;
  201.  
  202. {
  203.         Signaled when an object cannot be set in a container.  Same as 
  204.           AERegistry error errAEWriteDenied.
  205.     }
  206.     errOSACantAssign            = -10006;
  207.  
  208. {
  209.         Signaled by user scripts or applications when no actual error code
  210.           is to be returned.  Simply means "an error has occurred".  Most useful
  211.           in conjunction with an error message from the application.
  212.     }
  213.     errOSAGeneralError            = -2700;
  214.  
  215. { Signaled when there is an attempt to divide by zero }
  216.     errOSADivideByZero            = -2701;
  217.  
  218. { Signaled when integer or real value is too large to be represented }
  219.     errOSANumericOverflow        = -2702;
  220.  
  221. {
  222.         Signaled when application can't be launched or when it is remote and
  223.           program linking is not enabled.
  224.     }
  225.     errOSACantLaunch            = -2703;
  226.  
  227. { Signaled when an application can't respond to AppleEvents }
  228.     errOSAAppNotHighLevelEventAware = -2704;
  229.  
  230. { Signaled when an application's terminology resource is not readable }
  231.     errOSACorruptTerminology    = -2705;
  232.  
  233. { Signaled when the runtime stack overflows }
  234.     errOSAStackOverflow            = -2706;
  235.  
  236. { Signaled when a runtime internal data structure overflows }
  237.     errOSAInternalTableOverflow    = -2707;
  238.  
  239. {
  240.         Signaled when an intrinsic limitation is exceeded for the size of 
  241.           a value or data structure.
  242.     }
  243.     errOSADataBlockTooLarge        = -2708;
  244.  
  245.     errOSACantGetTerminology    = -2709;
  246.  
  247.     errOSACantCreate            = -2710;
  248.  
  249. {        Component-specific dynamic script errors:
  250.  
  251.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  252.     (Note that error codes from different scripting components in this range will
  253.     overlap.)
  254. }
  255. {        Static errors:
  256.  
  257.     These errors comprise what are commonly thought of as parse and compile-
  258.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  259.     of these may also occur at runtime.
  260. }
  261. { Signaled when data was not the right type and coercion is not allowed }
  262.     errOSATypeError                = errAEWrongDataType;
  263.  
  264. { Signaled when a message was sent to an object that didn't handle it }
  265.     OSAMessageNotUnderstood        = errAEEventNotHandled;
  266.  
  267. {
  268.         Signaled when a function to be returned doesn't exist.  (Probably only
  269.           useful in languages with first-class functions that distinguish between
  270.           functions and other values (two name spaces). This is different from
  271.           errOSAMessageNotUnderstood, which may be signaled when the method is
  272.           invoked.
  273.     }
  274.     OSAUndefinedHandler            = errAEHandlerNotFound;
  275.  
  276. { Signaled when a container can never have the requested object }
  277.     OSAIllegalAccess            = errAEAccessorNotFound;
  278.  
  279. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  280.     OSAIllegalIndex                = errAEIllegalIndex;
  281.  
  282. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  283.     OSAIllegalRange                = errAEImpossibleRange;
  284.  
  285. {
  286.         Signaled when an object can never be set in a container.  Same as 
  287.           AERegistry error errAENotModifiable.
  288.     }
  289.     OSAIllegalAssign            = -10003;
  290.  
  291. {
  292.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  293.          "<this> can't go after <that>").
  294.     }
  295.     OSASyntaxError                = -2740;
  296.  
  297. {
  298.         Signaled when another form of syntax was expected. (e.g. "expected
  299.           a <type> but found <this>").
  300.     }
  301.     OSASyntaxTypeError            = -2741;
  302.  
  303. { Signaled when a name or number is too long to be parsed }
  304.     OSATokenTooLong                = -2742;
  305.  
  306. {
  307.         Signaled when a parameter is missing for a function invocation.  Note
  308.           that in some languages, this error may occur at runtime.
  309.     }
  310.     OSAMissingParameter            = errAEDescNotFound;
  311.  
  312. {
  313.         Signaled when function is called with the wrong number of parameters,
  314.           or a parameter pattern cannot be matched.
  315.     }
  316.     OSAParameterMismatch        = errAEWrongNumberArgs;
  317.  
  318. {
  319.         Signaled when a formal parameter, local variable, or instance variable
  320.           is specified more than once.
  321.     }
  322.     OSADuplicateParameter        = -2750;
  323.  
  324. {
  325.         Signaled when a formal parameter, local variable, or instance variable
  326.           is specified more than once.
  327.     }
  328.     OSADuplicateProperty        = -2751;
  329.  
  330. {
  331.         Signaled when more than one handler is defined with the same name in 
  332.           a scope where the language doesn't allow it.
  333.     }
  334.     OSADuplicateHandler            = -2752;
  335.  
  336. { Signaled when a variable is accessed that has no value }
  337.     OSAUndefinedVariable        = -2753;
  338.  
  339. {
  340.         Signaled when a variable is declared inconsistently in the same scope,
  341.           such as both local and global.
  342.     }
  343.     OSAInconsistentDeclarations    = -2754;
  344.  
  345. {
  346.         Signaled when illegal control flow occurs in an application (no catcher
  347.           for throw, non-lexical loop exit, etc.).
  348.     }
  349.     OSAControlFlowError            = -2755;
  350.  
  351. {        Component-specific static script errors:
  352.  
  353.     The range -2760 thru -2779 is reserved for component-specific parsing and
  354.     compile-time errors. (Note that error codes from different scripting
  355.     components in this range will overlap.)
  356. }
  357. {        Dialect-specific script errors:
  358.  
  359.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  360.     scripting components that support dialects. (Note that error codes from
  361.     different scripting components in this range will overlap, as well as error
  362.     codes from different dialects in the same scripting component.)
  363. }
  364. {*************************************************************************
  365.     OSA Interface Descriptions
  366. **************************************************************************
  367.     The OSA Interface is broken down into a required interface, and several
  368.     optional interfaces to support additional functionality.  A given scripting
  369.     component may choose to support only some of the optional interfaces in
  370.     addition to the basic interface.  The OSA Component Flags may be used to 
  371.     query the Component Manager to find a scripting component with a particular
  372.     capability, or determine if a particular scripting component supports a 
  373.     particular capability.
  374. *************************************************************************}
  375. { OSA Component Flags: }
  376.     kOSASupportsCompiling        = $0002;
  377.     kOSASupportsGetSource        = $0004;
  378.     kOSASupportsAECoercion        = $0008;
  379.     kOSASupportsAESending        = $0010;
  380.     kOSASupportsRecording        = $0020;
  381.     kOSASupportsConvenience        = $0040;
  382.     kOSASupportsDialects        = $0080;
  383.     kOSASupportsEventHandling    = $0100;
  384.  
  385. { Component Selectors: }
  386.     kOSASelectLoad                = $0001;
  387.     kOSASelectStore                = $0002;
  388.     kOSASelectExecute            = $0003;
  389.     kOSASelectDisplay            = $0004;
  390.     kOSASelectScriptError        = $0005;
  391.     kOSASelectDispose            = $0006;
  392.     kOSASelectSetScriptInfo        = $0007;
  393.     kOSASelectGetScriptInfo        = $0008;
  394.     kOSASelectSetActiveProc        = $0009;
  395.     kOSASelectGetActiveProc        = $000A;
  396.  
  397. { Compiling: }
  398.     kOSASelectScriptingComponentName = $0102;
  399.     kOSASelectCompile            = $0103;
  400.     kOSASelectCopyID            = $0104;
  401.  
  402. { GetSource: }
  403.     kOSASelectGetSource            = $0201;
  404.  
  405. { AECoercion: }
  406.     kOSASelectCoerceFromDesc    = $0301;
  407.     kOSASelectCoerceToDesc        = $0302;
  408.  
  409. { AESending: }
  410.     kOSASelectSetSendProc        = $0401;
  411.     kOSASelectGetSendProc        = $0402;
  412.     kOSASelectSetCreateProc        = $0403;
  413.     kOSASelectGetCreateProc        = $0404;
  414.     kOSASelectSetDefaultTarget    = $0405;
  415.  
  416. { Recording: }
  417.     kOSASelectStartRecording    = $0501;
  418.     kOSASelectStopRecording        = $0502;
  419.  
  420. { Convenience: }
  421.     kOSASelectLoadExecute        = $0601;
  422.     kOSASelectCompileExecute    = $0602;
  423.     kOSASelectDoScript            = $0603;
  424.  
  425. { Dialects: }
  426.     kOSASelectSetCurrentDialect    = $0701;
  427.     kOSASelectGetCurrentDialect    = $0702;
  428.     kOSASelectAvailableDialects    = $0703;
  429.     kOSASelectGetDialectInfo    = $0704;
  430.     kOSASelectAvailableDialectCodeList = $0705;
  431.  
  432. { Event Handling: }
  433.     kOSASelectSetResumeDispatchProc = $0801;
  434.     kOSASelectGetResumeDispatchProc = $0802;
  435.     kOSASelectExecuteEvent        = $0803;
  436.     kOSASelectDoEvent            = $0804;
  437.     kOSASelectMakeContext        = $0805;
  438.  
  439. { scripting component specific selectors are added beginning with this value  }
  440.     kOSASelectComponentSpecificStart = $1001;
  441.  
  442. {        Mode Flags:
  443.  
  444.     Warning: These should not conflict with the AESend mode flags in
  445.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  446. }
  447. {
  448.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  449.           instruct the scripting component to not retain the "source" of an
  450.           expression.  This will cause the OSAGetSource call to return the error
  451.           errOSASourceNotAvailable if used.  However, some scripting components
  452.           may not retain the source anyway.  This is mainly used when either space
  453.           efficiency is desired, or a script is to be "locked" so that its
  454.           implementation may not be viewed.
  455.     }
  456.     kOSAModePreventGetSource    = $00000001;
  457.  
  458. {
  459.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  460.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  461.           indicate whether or not the script may interact with the user, switch
  462.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  463.           corresponding AESend mode supplied.
  464.     }
  465.     kOSAModeNeverInteract        = kAENeverInteract;
  466.     kOSAModeCanInteract            = kAECanInteract;
  467.     kOSAModeAlwaysInteract        = kAEAlwaysInteract;
  468.     kOSAModeDontReconnect        = kAEDontReconnect;
  469.  
  470. {
  471.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  472.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  473.           indicate whether or not AppleEvents should be sent with the
  474.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  475.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  476.           provide a more convenient default, i.e. not supplying any mode
  477.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  478.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  479.           without kAECanSwitchLayer.
  480.     }
  481.     kOSAModeCantSwitchLayer        = $00000040;
  482.  
  483. {
  484.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  485.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  486.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  487.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  488.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  489.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  490.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  491.           cause AESend to be called without kAEDontRecord.
  492.     }
  493.     kOSAModeDoRecord            = $00001000;
  494.  
  495. {
  496.         This is a mode flag for OSACompile that indicates that a context should
  497.           be created as the result of compilation. All handler definitions are
  498.           inserted into the new context, and variables are initialized by
  499.           evaluating their initial values in a null context (i.e. they must be
  500.           constant expressions).
  501.     }
  502.     kOSAModeCompileIntoContext    = $00000002;
  503.  
  504. {
  505.         This is a mode flag for OSACompile that indicates that the previous
  506.           script ID (input to OSACompile) should be augmented with any new
  507.           definitions in the sourceData rather than replaced with a new script.
  508.           This means that the previous script ID must designate a context.
  509.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  510.           to be implicitly used, causing any new definitions to be initialized
  511.           in a null context.
  512.     }
  513.     kOSAModeAugmentContext        = $00000004;
  514.  
  515. {
  516.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  517.           that output only need be human-readable, not re-compilable by OSACompile.
  518.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  519.           off of string values, long lists may have elipses, etc.
  520.     }
  521.     kOSAModeDisplayForHumans    = $00000008;
  522.  
  523. {
  524.         This mode flag may be passed to OSAStore in the case where the scriptID
  525.           is a context.  This causes the context to be saved, but not the context's
  526.           parent context.  When the stored context is loaded back in, the parent
  527.           will be kOSANullScript.
  528.     }
  529.     kOSAModeDontStoreParent        = $00010000;
  530.  
  531. {
  532.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  533.           be dispatched to the direct object of the event. The direct object (or
  534.           subject attribute if the direct object is a non-object specifier) will
  535.           be resolved, and the resulting script object will be the recipient of
  536.           the message. The context argument to OSAExecuteEvent will serve as the
  537.           root of the lookup/resolution process.
  538.     }
  539.     kOSAModeDispatchToDirectObject = $00020000;
  540.  
  541. {
  542.         This mode flag may be passed to OSAExecuteEvent to indicate that
  543.           components do not have to get the data of object specifier arguments.
  544.     }
  545.     kOSAModeDontGetDataForArguments = $00040000;
  546.  
  547. {*************************************************************************
  548.     OSA Basic Scripting Interface
  549. **************************************************************************
  550.     Scripting components must at least support the Basic Scripting interface.
  551. *************************************************************************}
  552. {        Loading and Storing Scripts:
  553.  
  554.     These routines allow scripts to be loaded and stored in their internal
  555.     (possibly compiled, non-text) representation.
  556. }
  557. { Resource type for scripts }
  558.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype;
  559.  
  560. {
  561.         Default type given to OSAStore which creates "generic" loadable script
  562.           data descriptors.
  563.     }
  564.     typeOSAGenericStorage        = kOSAScriptResourceType;
  565.  
  566.  
  567. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  568.     {$IFC NOT GENERATINGCFM}
  569.     INLINE $2F3C, $C, $0001, $7000, $A82A;
  570.     {$ENDC}
  571. {
  572.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  573.     
  574.         Errors:
  575.             badComponentInstance        invalid scripting component instance
  576.             errOSASystemError
  577.             errOSABadStorageType:        scriptData not for this scripting component
  578.             errOSACorruptData:            data seems to be corrupt
  579.             errOSADataFormatObsolete    script data format is no longer supported
  580.             errOSADataFormatTooNew        script data format is from a newer version
  581.         
  582.         ModeFlags:
  583.             kOSAModePreventGetSource
  584.     }
  585. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  586.     {$IFC NOT GENERATINGCFM}
  587.     INLINE $2F3C, $10, $0002, $7000, $A82A;
  588.     {$ENDC}
  589. {
  590.         OSAComponentFunctionInline(kOSASelectStore, 16);
  591.     
  592.         Errors:
  593.             badComponentInstance    invalid scripting component instance
  594.             errOSASystemError
  595.             errOSAInvalidID
  596.             errOSABadStorageType:    desiredType not for this scripting component
  597.         
  598.         ModeFlags:
  599.             kOSAModePreventGetSource
  600.             kOSAModeDontStoreParent
  601.     }
  602. { Executing Scripts: }
  603. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  604.     {$IFC NOT GENERATINGCFM}
  605.     INLINE $2F3C, $10, $0003, $7000, $A82A;
  606.     {$ENDC}
  607. {
  608.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  609.         This call runs a script.  The contextID represents the environment
  610.         with which global variables in the script are resolved.  The constant
  611.         kOSANullScript may be used for the contextID if the application wishes
  612.         to not deal with context directly (a default one is associated with each
  613.         scripting component instance).  The resultingScriptValueID is the 
  614.         result of evaluation, and contains a value which may be displayed using
  615.         the OSAGetSource call.  The modeFlags convey scripting component
  616.         specific information.
  617.     
  618.         Errors:
  619.             badComponentInstance    invalid scripting component instance
  620.             errOSASystemError
  621.             errOSAInvalidID
  622.             errOSAScriptError:        the executing script got an error
  623.     
  624.         ModeFlags:
  625.             kOSAModeNeverInteract
  626.             kOSAModeCanInteract
  627.             kOSAModeAlwaysInteract
  628.             kOSAModeCantSwitchLayer
  629.             kOSAModeDontReconnect
  630.             kOSAModeDoRecord
  631.     }
  632. { Displaying results: }
  633. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  634.     {$IFC NOT GENERATINGCFM}
  635.     INLINE $2F3C, $10, $0004, $7000, $A82A;
  636.     {$ENDC}
  637. {
  638.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  639.         This call is used to convert results (script value IDs) into displayable
  640.         text. The desiredType should be at least typeChar, and modeFlags are
  641.         scripting system specific flags to control the formatting of the
  642.         resulting text. This call differs from OSAGetSource in that (1) it
  643.         always produces at least typeChar, (2) is only works on script values,
  644.         (3) it may display it's output in non-compilable form (e.g. without
  645.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  646.         (4) it is required by the basic scripting interface.
  647.     
  648.         Errors:
  649.             badComponentInstance    invalid scripting component instance
  650.             errOSASystemError
  651.             errOSAInvalidID
  652.             errAECoercionFail:        desiredType not supported by scripting component
  653.     
  654.         ModeFlags:
  655.             kOSAModeDisplayForHumans
  656.     }
  657. { Getting Error Information: }
  658. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  659.     {$IFC NOT GENERATINGCFM}
  660.     INLINE $2F3C, $C, $0005, $7000, $A82A;
  661.     {$ENDC}
  662. {
  663.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  664.         Whenever script execution returns errOSAExecutionError, this routine
  665.         may be used to get information about that error.  The selector describes
  666.         the type of information desired about the error (various selectors are
  667.         listed below).  The desiredType indicates the data type of the result
  668.         desired for that selector.
  669.     
  670.         Errors:
  671.             badComponentInstance    invalid scripting component instance
  672.             errOSASystemError
  673.             errOSABadSelector:        selector not supported by scripting component
  674.             errAECoercionFail:        desiredType not supported by scripting component
  675.     }
  676. { OSAScriptError selectors: }
  677. {
  678.         This selector is used to determine the error number of a script error.
  679.         These error numbers may be either system error numbers, or error numbers
  680.         that are scripting component specific.
  681.         Required desiredTypes:    
  682.               typeShortInteger
  683.     }
  684.  
  685. CONST
  686.     kOSAErrorNumber                = keyErrorNumber;
  687.  
  688. {
  689.         This selector is used to determine the full error message associated
  690.         with the error number.  It should include the name of the application
  691.         which caused the error, as well as the specific error that occurred.
  692.         This selector is sufficient for simple error reporting (but see
  693.         kOSAErrorBriefMessage, below).
  694.         Required desiredTypes:
  695.             typeChar                    error message string
  696.     }
  697.     kOSAErrorMessage            = keyErrorString;
  698.  
  699. {
  700.         This selector is used to determine a brief error message associated with
  701.         the error number.  This message and should not mention the name of the
  702.         application which caused the error, any partial results or offending
  703.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  704.         kOSAErrorOffendingObject, below).
  705.         Required desiredTypes:
  706.               typeChar                    brief error message string
  707.     }
  708. {  0x65727262  }
  709.     kOSAErrorBriefMessage        = 'errb';
  710.  
  711. {
  712.         This selector is used to determine which application actually got the
  713.         error (if it was the result of an AESend), or the current application
  714.         if ....
  715.         Required desiredTypes:
  716.               typeProcessSerialNumber        PSN of the errant application
  717.               typeChar                    name of the errant application
  718.     }
  719. {  0x65726170  }
  720.     kOSAErrorApp                = 'erap';
  721.  
  722. {
  723.         This selector is used to determine any partial result returned by an 
  724.         operation. If an AESend call failed, but a partial result was returned,
  725.         then the partial result may be returned as an AEDesc.
  726.         Required desiredTypes:
  727.               typeBest                    AEDesc of any partial result
  728.     }
  729. {  0x70746c72   }
  730.     kOSAErrorPartialResult        = 'ptlr';
  731.  
  732. {
  733.         This selector is used to determine any object which caused the error
  734.         that may have been indicated by an application.  The result is an 
  735.         AEDesc.
  736.         Required desiredTypes:
  737.               typeBest                    AEDesc of any offending object
  738.     }
  739. {  0x65726f62   }
  740.     kOSAErrorOffendingObject    = 'erob';
  741.  
  742. {
  743.         This selector is used to determine the type expected by a coercion 
  744.         operation if a type error occurred.
  745.     }
  746. {  0x65727274   }
  747.     kOSAErrorExpectedType        = 'errt';
  748.  
  749. {
  750.         This selector is used to determine the source text range (start and 
  751.         end positions) of where the error occurred.
  752.         Required desiredTypes:
  753.               typeOSAErrorRange
  754.     }
  755. {  0x65726e67  }
  756.     kOSAErrorRange                = 'erng';
  757.  
  758. {
  759.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  760.         of type short.
  761.     }
  762. {  0x65726e67   }
  763.     typeOSAErrorRange            = 'erng';
  764.  
  765. { Field of a typeOSAErrorRange record of typeShortInteger }
  766. {  0x73726373    }
  767.     keyOSASourceStart            = 'srcs';
  768.  
  769. { Field of a typeOSAErrorRange record of typeShortInteger }
  770. {  0x73726365   }
  771.     keyOSASourceEnd                = 'srce';
  772.  
  773. { Disposing Script IDs: }
  774.  
  775. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  776.     {$IFC NOT GENERATINGCFM}
  777.     INLINE $2F3C, $4, $0006, $7000, $A82A;
  778.     {$ENDC}
  779. {
  780.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  781.         Disposes a script or context.
  782.     
  783.         Errors:
  784.             badComponentInstance    invalid scripting component instance
  785.             errOSASystemError
  786.             errOSAInvalidID
  787.     }
  788. { Getting and Setting Script Information: }
  789. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  790.     {$IFC NOT GENERATINGCFM}
  791.     INLINE $2F3C, $C, $0007, $7000, $A82A;
  792.     {$ENDC}
  793. {
  794.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  795.     
  796.         Errors:
  797.             badComponentInstance    invalid scripting component instance
  798.             errOSASystemError
  799.             errOSAInvalidID
  800.             errOSABadSelector:        selector not supported by scripting component
  801.                                     or selector not for this scriptID
  802.     }
  803. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  804.     {$IFC NOT GENERATINGCFM}
  805.     INLINE $2F3C, $C, $0008, $7000, $A82A;
  806.     {$ENDC}
  807. {
  808.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  809.     
  810.         Errors:
  811.             badComponentInstance    invalid scripting component instance
  812.             errOSASystemError
  813.             errOSAInvalidID
  814.             errOSABadSelector:        selector not supported by scripting component
  815.                                     or selector not for this scriptID
  816.     }
  817. { Manipulating the ActiveProc:
  818.  
  819.     Scripting systems will supply default values for these procedures if they
  820.     are not set by the client:
  821. }
  822. TYPE
  823.     OSAActiveProcPtr = ProcPtr;  { FUNCTION OSAActive(refCon: LONGINT): OSErr; }
  824.     OSAActiveUPP = UniversalProcPtr;
  825.  
  826. CONST
  827.     uppOSAActiveProcInfo = $000000E0; { FUNCTION (4 byte param): 2 byte result; }
  828.  
  829. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  830.     {$IFC NOT GENERATINGCFM }
  831.     INLINE $2E9F;
  832.     {$ENDC}
  833.  
  834. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  835.     {$IFC NOT GENERATINGCFM}
  836.     INLINE $205F, $4E90;
  837.     {$ENDC}
  838.  
  839. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  840.     {$IFC NOT GENERATINGCFM}
  841.     INLINE $2F3C, $8, $0009, $7000, $A82A;
  842.     {$ENDC}
  843. {
  844.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  845.         If activeProc is nil, the default activeProc is used.
  846.     
  847.         Errors:
  848.             badComponentInstance    invalid scripting component instance
  849.             errOSASystemError
  850.     }
  851. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  852.     {$IFC NOT GENERATINGCFM}
  853.     INLINE $2F3C, $8, $000A, $7000, $A82A;
  854.     {$ENDC}
  855. {
  856.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  857.     
  858.         Errors:
  859.             badComponentInstance    invalid scripting component instance
  860.             errOSASystemError
  861.     }
  862. {*************************************************************************
  863.     OSA Optional Compiling Interface
  864. **************************************************************************
  865.     Scripting components that support the Compiling interface have the 
  866.     kOSASupportsCompiling bit set in it's ComponentDescription.
  867. *************************************************************************}
  868. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  869.     {$IFC NOT GENERATINGCFM}
  870.     INLINE $2F3C, $4, $0102, $7000, $A82A;
  871.     {$ENDC}
  872. {
  873.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  874.         Given a scripting component, this routine returns the name of that
  875.         scripting component in a type that is coercable to text (typeChar).
  876.         The generic scripting component returns the name of the default
  877.         scripting component.  This name should be sufficient to convey to the
  878.         user the kind of script (syntax) he is expected to write.
  879.     
  880.         Errors:
  881.             badComponentInstance    invalid scripting component instance
  882.             errOSASystemError
  883.     }
  884. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  885.     {$IFC NOT GENERATINGCFM}
  886.     INLINE $2F3C, $C, $0602, $7000, $A82A;
  887.     {$ENDC}
  888. {
  889.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  890.         Coerces input desc (possibly text) into a script's internal format.
  891.         Once compiled, the script is ready to run.  The modeFlags convey
  892.         scripting component specific information.  The previous script ID
  893.         (result parameter) is made to refer to the newly compiled script,
  894.         unless it was originally kOSANullScript.  In this case a new script
  895.         ID is created and used.
  896.     
  897.         Errors:
  898.             badComponentInstance    invalid scripting component instance
  899.             errOSASystemError
  900.             errAECoercionFail:        sourceData is not compilable
  901.             errOSAScriptError:        sourceData was a bad script (syntax error)
  902.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  903.                                     valid on input
  904.     
  905.         ModeFlags:
  906.             kOSAModePreventGetSource
  907.             kOSAModeCompileIntoContext
  908.             kOSAModeAugmentContext
  909.             kOSAModeNeverInteract
  910.             kOSAModeCanInteract
  911.             kOSAModeAlwaysInteract
  912.             kOSAModeCantSwitchLayer
  913.             kOSAModeDontReconnect
  914.             kOSAModeDoRecord
  915.     }
  916. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  917.     {$IFC NOT GENERATINGCFM}
  918.     INLINE $2F3C, $8, $0104, $7000, $A82A;
  919.     {$ENDC}
  920. {
  921.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  922.         If toID is a reference to kOSANullScript then it is updated to have a
  923.         new scriptID value.  This call can be used to perform undo or revert
  924.         operations on scripts. 
  925.     
  926.         Errors:
  927.             badComponentInstance    invalid scripting component instance
  928.             errOSASystemError
  929.             errOSAInvalidID
  930.     }
  931. {*************************************************************************
  932.     OSA Optional GetSource Interface
  933. **************************************************************************
  934.     Scripting components that support the GetSource interface have the 
  935.     kOSASupportsGetSource bit set in it's ComponentDescription.
  936. *************************************************************************}
  937. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  938.     {$IFC NOT GENERATINGCFM}
  939.     INLINE $2F3C, $C, $0201, $7000, $A82A;
  940.     {$ENDC}
  941. {
  942.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  943.         This routine causes a compiled script to be output in a form (possibly
  944.         text) such that it is suitable to be passed back to OSACompile.
  945.  
  946.         Errors:
  947.             badComponentInstance    invalid scripting component instance
  948.             errOSASystemError
  949.             errOSAInvalidID
  950.             errOSASourceNotAvailable    can't get source for this scriptID
  951.     }
  952. {*************************************************************************
  953.     OSA Optional AECoercion Interface
  954. **************************************************************************
  955.     Scripting components that support the AECoercion interface have the 
  956.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  957. *************************************************************************}
  958. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  959.     {$IFC NOT GENERATINGCFM}
  960.     INLINE $2F3C, $C, $0301, $7000, $A82A;
  961.     {$ENDC}
  962. {
  963.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  964.         This routine causes script data to be coerced into a script value.
  965.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  966.         compiled script ID (mode flags for OSACompile may be used in this case).
  967.         Other scriptData descriptors create script value IDs.
  968.     
  969.         Errors:
  970.             badComponentInstance    invalid scripting component instance
  971.             errOSASystemError
  972.     
  973.         ModeFlags:
  974.             kOSAModePreventGetSource
  975.             kOSAModeCompileIntoContext
  976.             kOSAModeNeverInteract
  977.             kOSAModeCanInteract
  978.             kOSAModeAlwaysInteract
  979.             kOSAModeCantSwitchLayer
  980.             kOSAModeDontReconnect
  981.             kOSAModeDoRecord
  982.     }
  983. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  984.     {$IFC NOT GENERATINGCFM}
  985.     INLINE $2F3C, $10, $0302, $7000, $A82A;
  986.     {$ENDC}
  987. {
  988.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  989.         This routine causes a script value to be coerced into any desired form.
  990.         If the scriptID denotes a compiled script, then it may be coerced to 
  991.         typeAppleEvent.
  992.     
  993.         Errors:
  994.             badComponentInstance    invalid scripting component instance
  995.             errOSASystemError
  996.             errOSAInvalidID
  997.     }
  998. {*************************************************************************
  999.     OSA Optional AESending Interface
  1000. **************************************************************************
  1001.     Scripting components that support the AESending interface have the 
  1002.     kOSASupportsAESending bit set in it's ComponentDescription.
  1003. *************************************************************************}
  1004. {
  1005.     Scripting systems will supply default values for these procedures if they
  1006.     are not set by the client:
  1007. }
  1008. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1009.     {$IFC NOT GENERATINGCFM}
  1010.     INLINE $2F3C, $8, $0401, $7000, $A82A;
  1011.     {$ENDC}
  1012. {
  1013.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1014.         If sendProc is nil, the default sendProc is used.
  1015.     
  1016.         Errors:
  1017.             badComponentInstance    invalid scripting component instance
  1018.             errOSASystemError
  1019.     }
  1020. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1021.     {$IFC NOT GENERATINGCFM}
  1022.     INLINE $2F3C, $8, $0402, $7000, $A82A;
  1023.     {$ENDC}
  1024. {
  1025.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1026.     
  1027.         Errors:
  1028.             badComponentInstance    invalid scripting component instance
  1029.             errOSASystemError
  1030.     }
  1031. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1032.     {$IFC NOT GENERATINGCFM}
  1033.     INLINE $2F3C, $8, $0403, $7000, $A82A;
  1034.     {$ENDC}
  1035. {
  1036.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1037.         If createProc is nil, the default createProc is used.
  1038.     
  1039.         Errors:
  1040.             badComponentInstance    invalid scripting component instance
  1041.             errOSASystemError
  1042.     }
  1043. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1044.     {$IFC NOT GENERATINGCFM}
  1045.     INLINE $2F3C, $8, $0404, $7000, $A82A;
  1046.     {$ENDC}
  1047. {
  1048.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1049.     
  1050.         Errors:
  1051.             badComponentInstance    invalid scripting component instance
  1052.             errOSASystemError
  1053.     }
  1054. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1055.     {$IFC NOT GENERATINGCFM}
  1056.     INLINE $2F3C, $4, $0405, $7000, $A82A;
  1057.     {$ENDC}
  1058. {
  1059.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1060.         This routine sets the default target application for AE sending.
  1061.         It also establishes the default target from which terminologies come.
  1062.         It is effectively like having an AppleScript "tell" statement around
  1063.         the entire program.  If this routine is not called, or if the target 
  1064.         is a null AEDesc, then the current application is the default target.
  1065.     
  1066.         Errors:
  1067.             badComponentInstance    invalid scripting component instance
  1068.             errOSASystemError
  1069.     }
  1070. {*************************************************************************
  1071.     OSA Optional Recording Interface
  1072. **************************************************************************
  1073.     Scripting components that support the Recording interface have the 
  1074.     kOSASupportsRecording bit set in it's ComponentDescription.
  1075. *************************************************************************}
  1076. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1077.     {$IFC NOT GENERATINGCFM}
  1078.     INLINE $2F3C, $4, $0501, $7000, $A82A;
  1079.     {$ENDC}
  1080. {
  1081.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1082.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1083.         new script ID is created and returned.  If the current application has
  1084.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1085.         are sent to the application containing the text of each AppleEvent 
  1086.         recorded.
  1087.     
  1088.         Errors:
  1089.             badComponentInstance    invalid scripting component instance
  1090.             errOSASystemError
  1091.             errOSAInvalidID
  1092.             errOSARecordingIsAlreadyOn
  1093.     }
  1094. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1095.     {$IFC NOT GENERATINGCFM}
  1096.     INLINE $2F3C, $4, $0502, $7000, $A82A;
  1097.     {$ENDC}
  1098. {
  1099.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1100.         If compiledScriptID is not being recorded into or recording is not
  1101.         currently on, no error is returned.
  1102.     
  1103.         Errors:
  1104.             badComponentInstance    invalid scripting component instance
  1105.             errOSASystemError
  1106.             errOSAInvalidID
  1107.     }
  1108. {*************************************************************************
  1109.     OSA Optional Convenience Interface
  1110. **************************************************************************
  1111.     Scripting components that support the Convenience interface have the 
  1112.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1113. *************************************************************************}
  1114. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1115.     {$IFC NOT GENERATINGCFM}
  1116.     INLINE $2F3C, $10, $0601, $7000, $A82A;
  1117.     {$ENDC}
  1118. {
  1119.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1120.         This routine is effectively equivalent to calling OSALoad followed by
  1121.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1122.         resulting value ID is retained.
  1123.     
  1124.         Errors:
  1125.             badComponentInstance        invalid scripting component instance
  1126.             errOSASystemError
  1127.             errOSABadStorageType:        scriptData not for this scripting component
  1128.             errOSACorruptData:            data seems to be corrupt
  1129.             errOSADataFormatObsolete    script data format is no longer supported
  1130.             errOSADataFormatTooNew        script data format is from a newer version
  1131.             errOSAInvalidID
  1132.             errOSAScriptError:            the executing script got an error
  1133.     
  1134.         ModeFlags:
  1135.             kOSAModeNeverInteract
  1136.             kOSAModeCanInteract
  1137.             kOSAModeAlwaysInteract
  1138.             kOSAModeCantSwitchLayer
  1139.             kOSAModeDontReconnect
  1140.             kOSAModeDoRecord
  1141.     }
  1142. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1143.     {$IFC NOT GENERATINGCFM}
  1144.     INLINE $2F3C, $10, $0602, $7000, $A82A;
  1145.     {$ENDC}
  1146. {
  1147.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1148.         This routine is effectively equivalent to calling OSACompile followed by
  1149.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1150.         resulting value ID is retained.
  1151.     
  1152.         Errors:
  1153.             badComponentInstance    invalid scripting component instance
  1154.             errOSASystemError
  1155.             errAECoercionFail:        sourceData is not compilable
  1156.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1157.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1158.                                     valid on input
  1159.             errOSAScriptError:        the executing script got an error
  1160.     
  1161.         ModeFlags:
  1162.             kOSAModeNeverInteract
  1163.             kOSAModeCanInteract
  1164.             kOSAModeAlwaysInteract
  1165.             kOSAModeCantSwitchLayer
  1166.             kOSAModeDontReconnect
  1167.             kOSAModeDoRecord
  1168.     }
  1169. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1170.     {$IFC NOT GENERATINGCFM}
  1171.     INLINE $2F3C, $14, $0603, $7000, $A82A;
  1172.     {$ENDC}
  1173. {
  1174.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1175.         This routine is effectively equivalent to calling OSACompile followed by
  1176.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1177.         and the resulting value are is disposed.  Only the resultingText
  1178.         descriptor is retained.  If a script error occur during processing, the 
  1179.         resultingText gets the error message of the error, and errOSAScriptError
  1180.         is returned.  OSAScriptError may still be used to extract more 
  1181.         information about the particular error.
  1182.     
  1183.         Errors:
  1184.             badComponentInstance    invalid scripting component instance
  1185.             errOSASystemError
  1186.             errAECoercionFail:        sourceData is not compilable or 
  1187.                                     desiredType not supported by scripting component
  1188.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1189.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1190.                                     valid on input
  1191.             errOSAScriptError:        the executing script got an error
  1192.     
  1193.         ModeFlags:
  1194.             kOSAModeNeverInteract
  1195.             kOSAModeCanInteract
  1196.             kOSAModeAlwaysInteract
  1197.             kOSAModeCantSwitchLayer
  1198.             kOSAModeDontReconnect
  1199.             kOSAModeDoRecord
  1200.             kOSAModeDisplayForHumans
  1201.     }
  1202. {*************************************************************************
  1203.     OSA Optional Dialects Interface
  1204. **************************************************************************
  1205.     Scripting components that support the Dialects interface have the 
  1206.     kOSASupportsDialects bit set in it's ComponentDescription.
  1207. *************************************************************************}
  1208. {
  1209.     These calls allows an scripting component that supports different dialects
  1210.     to dynamically switch between those dialects.  Although this interface is
  1211.     specified, the particular dialect codes are scripting component dependent.
  1212. }
  1213. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1214.     {$IFC NOT GENERATINGCFM}
  1215.     INLINE $2F3C, $2, $0701, $7000, $A82A;
  1216.     {$ENDC}
  1217. {
  1218.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1219.     
  1220.         Errors:
  1221.             badComponentInstance    invalid scripting component instance
  1222.             errOSASystemError
  1223.             errOSANoSuchDialect:    invalid dialectCode
  1224.     }
  1225. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1226.     {$IFC NOT GENERATINGCFM}
  1227.     INLINE $2F3C, $4, $0702, $7000, $A82A;
  1228.     {$ENDC}
  1229. {
  1230.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1231.     
  1232.         Errors:
  1233.             badComponentInstance    invalid scripting component instance
  1234.             errOSASystemError
  1235.     }
  1236. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1237.     {$IFC NOT GENERATINGCFM}
  1238.     INLINE $2F3C, $4, $0703, $7000, $A82A;
  1239.     {$ENDC}
  1240. {
  1241.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1242.         This call return an AEList containing information about each of the
  1243.         currently available dialects of a scripting component.  Each item
  1244.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1245.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1246.         keyOSADialectScriptCode.
  1247.     
  1248.         Errors:
  1249.             badComponentInstance    invalid scripting component instance
  1250.             errOSASystemError
  1251.     }
  1252. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1253.     {$IFC NOT GENERATINGCFM}
  1254.     INLINE $2F3C, $A, $0704, $7000, $A82A;
  1255.     {$ENDC}
  1256. {
  1257.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1258.         This call gives information about the specified dialect of a scripting
  1259.         component. It returns an AEDesc whose type depends on the selector 
  1260.         specified. Available selectors are the same as the field keys for a
  1261.         dialect info record. The type of AEDesc returned is the same as the 
  1262.         type of the field that has same key as the selector.
  1263.     
  1264.         Errors:
  1265.             badComponentInstance    invalid scripting component instance
  1266.             errOSASystemError
  1267.              errOSABadSelector
  1268.             errOSANoSuchDialect:    invalid dialectCode
  1269.     }
  1270. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1271.     {$IFC NOT GENERATINGCFM}
  1272.     INLINE $2F3C, $4, $0705, $7000, $A82A;
  1273.     {$ENDC}
  1274. {
  1275.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1276.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1277.         and  OSAGetDialectInfo to get information on dialects.
  1278.         This call return an AEList containing dialect code for each of the
  1279.         currently available dialects of a scripting component. Each dialect
  1280.         code is a short integer of type typeShortInteger.
  1281.     
  1282.         Errors:
  1283.             badComponentInstance    invalid scripting component instance
  1284.             errOSASystemError
  1285.  
  1286.         Type of a dialect info record containing at least keyOSADialectName
  1287.         and keyOSADialectCode fields.
  1288.  
  1289.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1290.  
  1291.         Field of a typeOSADialectInfo record of typeChar.
  1292.         Field of a typeOSADialectInfo record of typeShortInteger.
  1293.         Field of a typeOSADialectInfo record of typeShortInteger.
  1294.         Field of a typeOSADialectInfo record of typeShortInteger.
  1295.     }
  1296. {*************************************************************************
  1297.     OSA Optional Event Handling Interface
  1298. **************************************************************************
  1299.     Scripting components that support the Event Handling interface have the 
  1300.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1301. *************************************************************************}
  1302. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1303.     {$IFC NOT GENERATINGCFM}
  1304.     INLINE $2F3C, $8, $0801, $7000, $A82A;
  1305.     {$ENDC}
  1306. {
  1307.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1308.         This function is used to set the ResumeDispatchProc that will be used
  1309.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1310.         found in the context, or the context event hander "continues" control
  1311.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1312.         may also be passed to this routine indicating that the handler registered
  1313.         in the application with AEInstallEventHandler should be used, or no
  1314.         dispatch should occur, respectively.
  1315.     
  1316.         Errors:
  1317.             badComponentInstance    invalid scripting component instance
  1318.             errOSASystemError
  1319.     }
  1320.  
  1321. CONST
  1322.     kOSAUseStandardDispatch        = kAEUseStandardDispatch;
  1323.  
  1324. {
  1325.         Special ResumeDispatchProc constant which may be passed to 
  1326.         OSASetResumeDispatchProc indicating that the handler registered
  1327.         in the application with AEInstallEventHandler should be used.
  1328.         
  1329.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1330.                 doesn't allow pointer types to be assigned to an enum.  All
  1331.                 constants must be assigned as enums to translate properly to
  1332.                 Pascal.
  1333.     }
  1334.     kOSANoDispatch                = kAENoDispatch;
  1335.  
  1336. {
  1337.         Special ResumeDispatchProc constant which may be passed to 
  1338.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1339.         
  1340.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1341.                 doesn't allow pointer types to be assigned to an enum.  All
  1342.                 constants must be assigned as enums to translate properly to
  1343.                 Pascal.
  1344.     }
  1345.     kOSADontUsePhac                = $0001;
  1346.  
  1347. {
  1348.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1349.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1350.         This causes the standard dispatch to be performed, except the phac
  1351.         handler is not called.  This is useful during tinkerability, when
  1352.         the phac handler is used to lookup a context associated with an event's 
  1353.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1354.         bypass the phac handler would result in an infinite loop.
  1355.     }
  1356.  
  1357. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1358.     {$IFC NOT GENERATINGCFM}
  1359.     INLINE $2F3C, $8, $0802, $7000, $A82A;
  1360.     {$ENDC}
  1361. {
  1362.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1363.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1364.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1365.     
  1366.         Errors:
  1367.             badComponentInstance    invalid scripting component instance
  1368.             errOSASystemError
  1369.     }
  1370. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1371.     {$IFC NOT GENERATINGCFM}
  1372.     INLINE $2F3C, $10, $0803, $7000, $A82A;
  1373.     {$ENDC}
  1374. {
  1375.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1376.         This call is similar to OSAExecute except the initial command to
  1377.         execute comes in the form of an AppleEvent.  If the contextID
  1378.         defines any event handlers for that event, they are used to process
  1379.         the event.  If no event handler can be found in the context
  1380.         errAEEventNotHandled is returned.  If an event handler is found and
  1381.         the hander "continues" control onward, the ResumeDispatchProc
  1382.         (registered with OSASetResumeDispatchProc, above) is called given the
  1383.         AppleEvent.  The result is returned as a scriptValueID.
  1384.     
  1385.         Errors:
  1386.             badComponentInstance    invalid scripting component instance
  1387.             errOSASystemError
  1388.             errOSAInvalidID
  1389.             errOSAScriptError:        the executing script got an error
  1390.             errAEEventNotHandled:    no handler for event in contextID
  1391.     
  1392.         ModeFlags:
  1393.             kOSAModeNeverInteract
  1394.             kOSAModeCanInteract
  1395.             kOSAModeAlwaysInteract
  1396.             kOSAModeCantSwitchLayer
  1397.             kOSAModeDontReconnect
  1398.             kOSAModeDoRecord
  1399.     }
  1400. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1401.     {$IFC NOT GENERATINGCFM}
  1402.     INLINE $2F3C, $10, $0804, $7000, $A82A;
  1403.     {$ENDC}
  1404. {
  1405.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1406.         This call is similar to OSADoScript except the initial command to
  1407.         execute comes in the form of an AppleEvent, and the result is an 
  1408.         AppleEvent reply record.  If the contextID defines any event handlers
  1409.         for that event, they are used to process the event.  If no event handler
  1410.         can be found in the context errAEEventNotHandled is returned.  If an
  1411.         event handler is found and the hander "continues" control onward, the
  1412.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1413.         called given the AppleEvent.  The result is returned in the form of an
  1414.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1415.         if the ResumeDispatchProc returns a reply event indicating an error,
  1416.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1417.         should never return errOSAScriptError).  Any error result returned by
  1418.         the ResumeDispatchProc will be returned by OSADoEvent.
  1419.     
  1420.         Errors:
  1421.             badComponentInstance    invalid scripting component instance
  1422.             errOSASystemError
  1423.             errOSAInvalidID
  1424.             errAEEventNotHandled:    no handler for event in contextID
  1425.     
  1426.         ModeFlags:
  1427.             kOSAModeNeverInteract
  1428.             kOSAModeCanInteract
  1429.             kOSAModeAlwaysInteract
  1430.             kOSAModeCantSwitchLayer
  1431.             kOSAModeDontReconnect
  1432.             kOSAModeDoRecord
  1433.     }
  1434. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1435.     {$IFC NOT GENERATINGCFM}
  1436.     INLINE $2F3C, $C, $0805, $7000, $A82A;
  1437.     {$ENDC}
  1438. {
  1439.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1440.         Makes a new empty context which may be passed to OSAExecute or 
  1441.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1442.         created. If parentContext is kOSANullScript then the resulting context
  1443.         does not inherit bindings from any other context.
  1444.     
  1445.         Errors:
  1446.             badComponentInstance    invalid scripting component instance
  1447.             errOSASystemError
  1448.             errOSAInvalidID
  1449.             errAECoercionFail:        contextName is invalid
  1450.     }
  1451.  
  1452. {$ALIGN RESET}
  1453. {$POP}
  1454.  
  1455. {$SETC UsingIncludes := OSAIncludes}
  1456.  
  1457. {$ENDC} {__OSA__}
  1458.  
  1459. {$IFC NOT UsingIncludes}
  1460.  END.
  1461. {$ENDC}
  1462.